<?php
// 删除医生信息
// header("content-type:text/html;charset=UTF-8");
include_once("conn.php");

$departid = $_GET["departid"];

$select_doc = "SELECT * FROM doc_infos WHERE doc_TypeMain = '".$departid."'";

if($result_doc = mysqli_query($connect_DB, $select_doc)){
    if(mysqli_num_rows($result_doc) <= 0){
        $delete_doc = "DELETE FROM department_infos WHERE department_ID = '".$departid."'";
        if(mysqli_query($connect_DB, $delete_doc)){
            echo "<script>alert('删除成功！');location='admin_ControlDepartments.php';</script>";
        }else{
            echo "<script>alert('删除失败！请重试！');history.go(-1);</script>";
        }
    }else{
        echo "<script>alert('删除失败！该科室还有医生信息！');history.go(-1);</script>";
    }
}else{
    echo "<script>alert('查询科室人数失败！');history.go(-1);</script>";
}

$connect_DB->close();
?>